package com.txc.common.global.exception;

import com.txc.common.global.result.IResultCode;
import com.txc.common.global.result.ResultCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 用户异常
 *
 * @ClassName: CustomException
 * @Author: TXC
 * @Date: 2022-07-30 10:12
 **/
@EqualsAndHashCode(callSuper = true)
@Data
public class CustomException extends RuntimeException {
    protected Integer code;
    protected String message;

    public CustomException(IResultCode resultCode, Throwable e) {
        super(resultCode.getMessage(), e);
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
    }

    public CustomException(IResultCode resultCode) {
        this(resultCode, null);
    }

}
